package com.synthefact.daj.model;

import java.util.Set;

//TODO describe ProgramIf in terms of its data and operations, remove unnecessary methods 
/**
 * Interface for a program. A program executes on a node.
 * 
 * <p>
 * Copyright (C) 2011 Synthefact
 * <p>
 * Based on code from (c) 1997, Wolfgang Schreiner <Wolfgang.Schreiner@risc.uni-linz.ac.at>
 * http://www.risc.uni-linz.ac.at/software/daj
 */
public interface ProgramIf {

    /**
     * Sets the {@link NodeIf} where this program will execute.
     * 
     * @param node
     *            the node where this program will execute.
     */
    void setNode(NodeIf node);

    /**
     * Gets the {@link ProgramStatus} of this program.
     * 
     * @return the status of this program.
     */
    ProgramStatus getStatus();

    // TODO Programs don't need to get channels if they can get nodes

    /**
     * Returns the {@link ChannelIf} with the given input channel index.
     * 
     * @param inChannelIndex
     *            the index of the input channel to return.
     * @return the input channel with the given input channel index.
     */
    ChannelIf getInChannel(int inChannelIndex);

    /**
     * Returns the {@link java.util.Set} of {@link ChannelIf}s for this program.
     * 
     * @return the {@link java.util.Set} of input channels for this program.
     */
    Set<ChannelIf> getInChannelSet();

    /**
     * Returns the {@link ChannelIf} with the given index.
     * 
     * @param outChannelIndex
     *            the index of the output channel to return.
     * @return the output channel with the given index.
     */
    ChannelIf getOutChannel(int outChannelIndex);

    /**
     * Returns the {@link java.util.Set} of {@link ChannelIf} for this program.
     * 
     * @return the {@link java.util.Set} of output channels for this program.
     */
    Set<ChannelIf> getOutChannelSet();

    /**
     * Tests if the given global assertion is true. Network exits if the test
     * fails.
     * <p>
     * TODO: find a better place for this method.
     * 
     * @param globalAssertion
     */
    void test(GlobalAssertionIf globalAssertion);

    /**
     * The main for this program.
     */
    void main();
}
